// 1----------------------------------------------
async function async1() {
  console.log('async1 start');
  await async2(); // 阻塞后面代码的执行
  console.log('async1 end');
  setTimeout(() => {
    console.log('setTimeout1');
  }, 0);
}

async function async2() {
  setTimeout(() => {
    console.log('setTimeout2');
  }, 0);
  console.log('async2');
}

async1()
setTimeout(() => {
  console.log('setTimeout3');
}, 0);
console.log('start')
/*
async1 start
async2
start
async1 end
setTimeout2
setTimeout3
setTimeout1*/

// 2----------------------------------------------
console.log('1')
setTimeout(() => {
  console.log('2')
  process.nextTick(() => {
    console.log('3')
  })
  new Promise(resolve => {
    console.log('4')
    resolve()
  }).then(() => {
    console.log('5')
  })
})
process.nextTick(() => {
  console.log('6')
})
new Promise(resolve => {
  console.log('7')
  resolve()
}).then(() => {
  console.log('8')
})
setTimeout(() => {
  console.log('9')
  process.nextTick(() => {
    console.log('10')
  })
  new Promise(resolve => {
    console.log('11')
    resolve()
  }).then(() => {
    console.log('12')
  })
})
